package com.ljsw.dialog.PKBiaoPaiDiaglog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;

import com.ljsw.activity.R;
import com.ljsw.adapter.PKReconciDialogadapter;
import com.ljsw.util.DialogListener;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lianchao on 2020/10/22.
 */

public class PKReconciDialog {
    public PKReconciDialog(Context context) {
        super();
        this.context = context;
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        display = windowManager.getDefaultDisplay();//获取屏幕分辨率
    }

    public PKReconciDialog(Context context, DialogListener dialogListener) {
        super();
        this.context = context;
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        display = windowManager.getDefaultDisplay();//获取屏幕分辨率
    }

    private Context context;
    private Display display;
    private Dialog dialog;
    private LinearLayout yg_layout;
    private TextView danwei_name,//单位名称|机构名称

    dialog_addbiaopai; ///  显示标牌
    private ImageView image_yuangong;//图片
    private Spinner spinner;
    private ListView listview001;

    public PKReconciDialog builder() {
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_add_biaopai, null);
        listview001 = (ListView) view.findViewById(R.id.listview001);
//        dialog_addbiaopai = (TextView) view.findViewById(R.id.dialog_addbiaopai);
//        spinner = (Spinner) view.findViewById(R.id.dialog_addbiaopaispin);
        // 添加Dialog样式
        dialog = new Dialog(context, R.style.YuangongDialog);
        dialog.setContentView(view);
        dialog.setCanceledOnTouchOutside(true);// 设置点击Dialog外部任意区域不关闭Dialog
        // 调整dialog背景大小
        yg_layout.setLayoutParams(new FrameLayout.LayoutParams(
                (int) (display.getWidth() * 0.85), LinearLayout.LayoutParams.WRAP_CONTENT));
        return this;
    }


    /**
     * 设置单位名
     *
     * @param title
     * @return
     */
    public PKReconciDialog setDanweiName(String title) {
        danwei_name.setText(title);
        return this;
    }

    /**
     * 设置图片
     *
     * @param =
     * @return
     */
    public PKReconciDialog setHeadBitmap(Bitmap map) {
        image_yuangong.setImageBitmap(map);
        return this;
    }

    public PKReconciDialog setBiaopai(String sss) {
        SpinnerAdapter adapter = null;
        ArrayList<String> list = new ArrayList<String>();
        return this;
    }



    public PKReconciDialog setListOn(List<String> sss) {
        PKReconciDialogadapter adapter = null;
        ArrayList<String> list = new ArrayList<String>();
        return this;
    }

    /**
     * 点击事件
     *
     * @param text
     * @param listener
     * @return
     */
    public PKReconciDialog setQueDing(String text,
                                      final View.OnClickListener listener) {
        yg_layout.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                listener.onClick(v);
                dialog.dismiss();
            }
        });
        return this;
    }

    public void show() {
        dialog.show();
    }

}
